import request from '@/utils/request'
// 定义模块前缀
const prefix = '/user'

// 获取登录验证码
export const getCaptcha = () => {
	return request({
	    url: `/getCaptcha`,
	    method: 'get',
	})
}

// 登录
export const login = (data) => {
	return request({
	    url: `${prefix}/login`,
	    method: 'post',
	    data
	})
}

// 注册
export const register = (data) => {
	return request({
	    url: `${prefix}/register`,
	    method: 'post',
	    data
	})
}

// 登录时获取用户信息
export const getUserInfo = () => {
	return request({
	    url: `${prefix}/getUserInfo`,
	    method: 'get',
	})
}

// 退出登录
export const logout = (data) => {
	return request({
	    url: `${prefix}/logout`,
	    method: 'post',
		data
	})
}

// 提交表单内容
export const updateUserInfo = (data) => {
	return request({
	    url: `${prefix}/updateUserInfo`,
	    method: 'put',
	    data
	})
}

// 注销接口
export const delAccount = () => {
	return request({
	    url: `${prefix}/delAccount`,
	    method: 'post',
	})
}

// 发送邮箱验证码接口
export const sendEmailCode = (data) => {
	return request({
	    url: `${prefix}/sendEmailCode`,
	    method: 'post',
	    data
	})
}

// 重置密码接口
export const resetPassword = (data) => {
	return request({
	    url: `${prefix}/resetPassword`,
	    method: 'post',
	    data
	})
}


// 关注用户接口
export const follow = (data) => {
	return request({
	    url: `${prefix}/follow`,
	    method: 'post',
        data
	})
}

// 取消关注接口
export const cancelFollow = (data) => {
	return request({
	    url: `${prefix}/cancelFollow`,
	    method: 'delete',
        data
	})
}

// 查询用户是否关注过
export const findFollowState = (params) => {
	return request({
	    url: `${prefix}/findFollowState`,
	    method: 'get',
        params
	})
}

// 绑定手机号
export const bindPhone = (data) => {
	return request({
	    url: `${prefix}/bindPhone`,
	    method: 'post',
        data
	})
}

// 查询聊天记录接口
export const getChatRecord = (params) => {
	return request({
	    url: `${prefix}/getChatRecord`,
	    method: 'get',
        params
	})
}

// 修改撤回状态
export const updateRevokeState = () => {
	return request({
	    url: `${prefix}/updateRevokeState`,
	    method: 'put',
	})
}

// 撤回消息接口
export const revokeMsg = (data) => {
	return request({
	    url: `${prefix}/revokeMsg`,
	    method: 'delete',
        data
	})
}

// 查询用户未读消息列表
export const getNoReadMsgList = () => {
	return request({
	    url: `${prefix}/getNoReadMsgList`,
	    method: 'get',
	})
}

// 查询用户未读消息总数
export const getNoReadMsgCount = () => {
	return request({
	    url: `${prefix}/getNoReadMsgCount`,
	    method: 'get',
	})
}

// 批量修改用户消息状态
export const updateMsgState = (data) => {
	return request({
	    url: `${prefix}/updateMsgState`,
	    method: 'put',
        data
	})
}

// 查询登录人好友
export const getFriendList = () => {
	return request({
	    url: `${prefix}/getFriendList`,
	    method: 'get',
	})
}

// 将好友发送的消息设为已读
export const updateFriendMsgState = (data) => {
	return request({
	    url: `${prefix}/updateFriendMsgState`,
	    method: 'put',
		data
	})
}

// 刷新token
export const refreshTokenApi = (data) => {
	return request({
	    url: `${prefix}/refreshToken`,
	    method: 'post',
		data
	})
}
